package datamodel;

import java.util.ArrayList;
import java.util.List;

import communication.Attribute;
import communication.DomainClass;

public class DomainClassHelper {

	public static String getConstructorParameter(DomainClass clzz) {
		String parameterList = "";
		for (int index = 0; index < getNonCollectionAttributes(clzz).size(); index++) {
			Attribute attribute = clzz.getAttributes().get(index);
			if (!attribute.isIsCollection()) {
				parameterList += attribute.getAttributeType().getName() + " " + attribute.getName();
				if (index != getNonCollectionAttributes(clzz).size() - 1) {
					parameterList += ", ";
				}
			}
		}
		return parameterList;
	}
	
	public static List<Attribute> getCollectionAttributes(DomainClass clzz) {
		List<Attribute> attributes = new ArrayList<Attribute>();
		for (Attribute attribute : clzz.getAttributes()) {
			if(attribute.isIsCollection()){
				attributes.add(attribute);
			}			
		}
		return attributes;
	}
	
	public static List<Attribute> getNonCollectionAttributes(DomainClass clzz) {
		List<Attribute> attributes = new ArrayList<Attribute>();
		for (Attribute attribute : clzz.getAttributes()) {
			if(!attribute.isIsCollection()){
				attributes.add(attribute);
			}			
		}
		return attributes;
	}
}
